package com.zbkj.crmeb.store.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zbkj.crmeb.store.dao.ChannelFreeShippingActivityCityDao;
import com.zbkj.crmeb.store.model.ChannelFreeShippingActivityCity;
import com.zbkj.crmeb.store.service.ChannelFreeShippingActivityCityService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class ChannelFreeShippingActivityCityServiceImpl extends ServiceImpl<ChannelFreeShippingActivityCityDao, ChannelFreeShippingActivityCity> implements ChannelFreeShippingActivityCityService {

    /**
     * 功能描述: 删除不包邮城市
     * @Param: [activityId]
     * @Return: java.lang.Boolean
     * @Author: wangzh
     * @Date: 2022/12/30 14:53
     */
    @Override
    public Boolean removeCityByActivityId(Integer activityId) {
        return this.remove(Wrappers.<ChannelFreeShippingActivityCity>lambdaQuery()
                .eq(ChannelFreeShippingActivityCity::getActivityId, activityId));
    }

    /**
     * 功能描述: 获取不包邮城市id
     * @Param: [activityIds]
     * @Return: java.util.List<java.lang.Integer>
     * @Author: wangzh
     * @Date: 2022/12/30 15:54
     */
    @Override
    public List<Integer> getCityId(List<Integer> activityIds) {
        List<ChannelFreeShippingActivityCity> list = this.list(Wrappers.<ChannelFreeShippingActivityCity>lambdaQuery()
                .in(ChannelFreeShippingActivityCity::getActivityId, activityIds));
        if (CollectionUtils.isEmpty(list)){
            return new ArrayList<>();
        }
        return list.stream().map(ChannelFreeShippingActivityCity::getCityId).collect(Collectors.toList());
    }
}
